Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add penumbra angle to spotLight #5078

Closed
wants to merge 1 commit into from

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Jul 17, 2014

Add an additional option to THREE.SpotLight called penumbraAngle.
This angle will be added to the angle of the spotlight to create a
"falloff" cone. The area within both cones is lit as normal. The area
outside of the falloff code is not lit. The area between the inner and
falloff cones is smoothly faded away as it approaches the edge of the
falloff cone.

Before:

screen shot 2014-07-17 at 9 52 16 am

After (10 degree penumbra):

screen shot 2014-07-17 at 9 52 13 am

Add an additional option to `THREE.SpotLight` called `penumbraAngle`.
This angle will be added to the angle of the spotlight to create a
"falloff" cone. The area within both cones is lit as normal. The area
outside of the falloff code is not lit. The area between the inner and
falloff cones is smoothly faded away as it approaches the edge of the
falloff cone.
@@ -69,6 +69,8 @@ THREE.UniformsLib = {
"spotLightDirection" : { type: "fv", value: [] },
"spotLightDistance" : { type: "fv1", value: [] },
"spotLightAngleCos" : { type: "fv1", value: [] },
"spotLightOuterAngleCos" : { type: "fv1", value: [] },
"spotLightAngleCosDiff" : { type: "fv1", value: [] },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the difference can be computed in the shader, instead. This may be more efficient, but it seems strange to me to pass in redundant information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to actually benchmark the performance difference, but at first glance it seemed pretty significant

@WestLangley
Copy link
Collaborator

How do penumbra and exponent work together in your view? Can arbitrary values produce reasonable shadows, or are there only certain combinations that look good together?

Also, you should probably target the dev branch. Please see the Wiki article How to Contribute to three.js.

@sgrif
Copy link
Contributor Author

sgrif commented Jul 17, 2014

<_< I always forget to target dev. I'll retarget and re-open.

@sgrif sgrif closed this Jul 17, 2014
@sgrif sgrif reopened this Jul 17, 2014
@sgrif sgrif closed this Jul 17, 2014
@sgrif
Copy link
Contributor Author

sgrif commented Jul 17, 2014

Yes, penumbra and exponent work fine together, if the exponent is a value in which the edge is still visible. They produce very different, but independent results.

@WestLangley
Copy link
Collaborator

Yes, penumbra and exponent work fine together, if the exponent is a value in which the edge is still visible. They produce very different, but independent results.

That is what I expected -- which means that they do not work fine together.

Perhaps a different parameterization would be appropriate. I would be glad to suggest something if I had an idea. : - )

Also, renderer.shadowMapType may be a factor.

This issue must have been addressed somewhere before, no?

@sgrif
Copy link
Contributor Author

sgrif commented Jul 17, 2014

That is what I expected -- which means that they do not work fine together.

To me, they produce the expected result. For a value like 10, there is no difference, as the edge was never visible:

screen shot 2014-07-17 at 12 35 59 pm

For a value such as 4, it performs as expected, the edge is affected by the falloff from the penumbra, and then is darkened by the exponent.

screen shot 2014-07-17 at 12 36 16 pm
screen shot 2014-07-17 at 12 36 28 pm

Also, renderer.shadowMapType may be a factor.

Shadows aren't affected by this.

With penumbra:
screen shot 2014-07-17 at 12 33 22 pm

Without:
screen shot 2014-07-17 at 12 33 02 pm

This issue must have been addressed somewhere before, no?

I wish...

@WestLangley
Copy link
Collaborator

I like what you are trying to do. I am just concerned about the parameter combinations, and maybe your modeling approach. The exponent parameter was supposed to be modeling this effect already -- at least that was my understanding.

If you would be willing to add DAT.GUI sliders to your example showing how parameters angle ( 0-pi/2 ), exponent ( 0-infinity) , and penumbra can be varied over their full dynamic ranges, that would be great.

@sgrif
Copy link
Contributor Author

sgrif commented Jul 17, 2014

@WestLangley Re-opened at #5080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants